package com.app.mymusic.test.dagger2;

import com.app.mymusic.utils.LogUtil;
import com.app.mymusic.utils.RetrofitUtil;

import rx.Observable;
import rx.Subscriber;

/**
 * Created by Administrator on 2016-12-1.
 */

public class UserModel  {

    public UserModel() {
    }

    public Observable<User> getUsers(int lastIdQueried, boolean update, final DaggerPresenter.GetCallback  callback) {
        RetrofitUtil.getInstace().getData(new Subscriber<User>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {
                LogUtil.showLog("error:"+e.toString());
                callback.error();
            }

            @Override
            public void onNext(User user) {
                try {
                    LogUtil.showLog(user.getName());
                    LogUtil.showLog(user.getAddress());
                    LogUtil.showLog(user.getId()+"");
                    LogUtil.showLog(user.getEmail());
                    callback.sucess();
                } catch (Exception e) {
                    e.printStackTrace();
                    callback.error();
                }

            }
        },"ip");
        return null;
    }
}
